#ifndef RESOURCE_SERVER_H
#define RESOURCE_SERVER_H
#include <memory>
#include "async/asocket.h"


class Connection;


class Server : public asocket
{
public:
    friend class Connection;
    explicit Server(event_loop* l, int max_connections=1024);
    ~Server()override;

    void listen(const std::string& host, uint16_t port, int backlog = 1024);
    inline void close() { on_close(); }

protected:
    void on_read()override;
    void on_close()override;

protected:
    std::vector<int> valid_conn_indices;
    std::vector<Connection> connections;
};


#endif //RESOURCE_SERVER_H
